#ifndef OPTIMIZATIONENVIRONMENT_H_
#define OPTIMIZATIONENVIRONMENT_H_

#include "AbstractEnvironment.h"

/**
  * Class that represents environment for function optimization
  * @author Łukasz Szybka
  */
class OptimizationEnvironment : public AbstractEnvironment
{
public:
    OptimizationEnvironment(int populationSize,
                            QVector< QPair<double, double> > _rangeVector,
                            int precision,
                            double (*_formulaPointer)(QVector<double>));

    QString decodeChromosome(const Chromosome& chrom);

protected:
    void fitnessFunction(Chromosome& chrom);

    QVector< QPair<double, double> > rangeVector;
    QVector<int> argumentBitsLegth;

private:

    /**
      * Pointer to formula function
      */
    double (*formulaPointer)(QVector<double>);

    double decodeArgument(QString binaryRepresentation,
                          double lowerBound,
                          double upperBound,
                          int precisionBits);

    int countPrecisionBits(double lowerBound, double upperBound, int precision);

};

#endif /*OPTIMIZATIONENVIRONMENT_H_*/
